const ObjectKeyValueSwitch = (obj) => {
  const newObj = {};
  Object.keys(obj).forEach((key) => (newObj[obj[key]] = key));
  return newObj;
};

export const ECenter = {
  Z: "机器人",
  A: "售前售后",
  E: "校园大数据",
  B: "信息数据管理指挥中心",
  F: "物联网管控中心",
  C: "网上课堂中心",
  G: "校园安全中心",
  D: "办公服务中心",
  H: "后勤总务中心",
  I: "教学管理中心",
  J: "广播宣传中心",
  K: "资源中心",
};

export const centerSelectData = Object.entries(ECenter).map(([k, v]) => ({
  value: k,
  label: v,
}));

export const EFunctionType = {
  1: "公共类",
  2: "学生类",
  3: "教师类",
  4: "教学资源类",
  5: "成绩类",
  6: "考勤类",
  7: "设备类",
  8: "建筑物类",
  10: "其它",
};

export const functionTypeSelectData = Object.entries(EFunctionType).map(
  ([k, v]) => ({
    value: k,
    label: v,
  })
);

// 表格显示 T S A P
export const ERole = {
  ADMIN: "管理员",
  TEACHER: "老师",
  STUDENT: "学生",
  PARENT: "家长",
  COMMON: "管理员、老师、学生、家长",
  COMMON_TS: "老师、学生",
  COMMON_TA: "管理员、老师",
  COMMON_TP: "老师、家长",
  COMMON_SA: "管理员、学生",
  COMMON_SP: "学生、家长",
  COMMON_AP: "管理员、家长",
  COMMON_TSA: "管理员、老师、学生",
  COMMON_TSP: "老师、学生、家长",
  COMMON_SAP: "管理员、学生、家长",
};

// 筛选框显示
export const roleSelectData = Object.entries(ERole)
  .slice(0, 4)
  .map(([k, v]) => ({
    value: k,
    label: v,
  }));

export const EVersion = {
  1: "大学",
  2: "中小学",
  4: "中职",
  3: "中小学、大学",
  5: "大学、中职",
  6: "中小学、中职",
  7: "中小学、大学、中职",
};

export const versionSelectData = Object.entries(EVersion)
  .slice(0, 2)
  .map(([k, v]) => ({
    value: k,
    label: v,
  }));

export const EInputDevice = {
  1: "PC端",
  2: "移动端",
  3: "PC端、移动端",
};

export const EInstructType02 = {
  0: "--",
  1: "售前",
  2: "售后",
  3: "售前、售后"
};

export const EInstructType = {
  DATA_RETURN: "数据返回",
  OPEN_OPERATION: "打开操作",
  CONTROL_OPERATION: "控制操作",
  RECOMMEND_INSTRUCT: "推荐指令",
};

export const EInstructTypeR = ObjectKeyValueSwitch(EInstructType);

export const searchTypeData = [
  {
    label: "查询指令名称",
    value: "instructName",
  },
  {
    label: "查询模块",
    value: "moduleName",
  },
  {
    label: "查询模块ID",
    value: "moduleId",
  },
  {
    label: "查询指令关键词",
    value: "commonSentence",
  },
];

export const oneNetUserType = {
  0: "管理员",
  1: "教师",
  2: "学生",
  3: "家长",
  11: "其它教职工",
};

export const oneNetUserTypeSelectData = Object.entries(oneNetUserType).map(
  ([k, v]) => ({
    value: k,
    label: v,
  })
);

export const oneNetSearchTypeData = [
  {
    label: "查询功能、数据名称",
    value: "serverName",
  },
  // {
  //   label: "查询常用命令词",
  //   value: "sentences",
  // },
];

export const RELEARN_STATUS = {
  0: "未处理",
  1: "已处理",
};

export const RELEARN_STATUS_DATA = Object.entries(RELEARN_STATUS).map(
  ([k, v]) => ({
    value: k,
    label: v,
  })
);

export const RELEARN_USER_REATION = {
  "-1": "所有异常结果",
  2: "用户不同意",
  1001: "用户同意",
};

export const RELEARN_USER_REATION_DATA = Object.entries(
  RELEARN_USER_REATION
).map(([k, v]) => ({
  value: k,
  label: v,
}));
